import java.math.BigDecimal;

/**
 * 满减策略
 *
 * @author fy
 * @date 2022/8/23 21:55
 */
public class ReduceStrategy implements PriceStrategy {

    /**
     * 满多少金额
     */
    private double overPrice;

    /**
     * 减多少金额
     */
    private double reducePrice;

    public ReduceStrategy(double overPrice, double reducePrice) {
        this.overPrice = overPrice;
        this.reducePrice = reducePrice;
    }

    @Override
    public double calcPrice(double originalPrice) {
        if (originalPrice >= overPrice) {
            return BigDecimal.valueOf(originalPrice).subtract(BigDecimal.valueOf(reducePrice)).doubleValue();
        } else {
            return originalPrice;
        }
    }

}
